<template>
  <div class="password-wrap">
    <div class="myself-item">
        <div class="item-list box box-align-center box-pack-between">
            <div class="title">旧密码：</div>
            <input v-model="pwd" placeholder='请输入旧密码' type="password" maxlength="18"  placeholder-style='text-align:right'>
        </div>
        <div class="item-list box box-align-center box-pack-between">
            <div class="title">新密码：</div>
            <input v-model="newPwd" placeholder='请输入6-18位新密码' type="password"   maxlength="18"  placeholder-style='text-align:right'>
        </div>
        <div bindtap='linkToPage' class="item-list box box-align-center box-pack-between">
            <div class="title">再次输入新密码：</div>
            <input v-model="confirmPwd" placeholder='请再次输入6-18位新密码' type="password"
             maxlength="18"   placeholder-style='text-align:right'>
        </div>
    </div>
    <div class='footer-submit' @click="login">提交</div>
  </div>
</template>

<script>
let CONSTANT = require('../../../wechat/static/constant/constant.js'),
    common = require("../../../wechat/static/common/common.js"),
    wsService = require("../../../wechat/static/common/wechat-jsdk.js");
export default {
  components: {

  },
  data () {
    return {
        pwd:'',
        newPwd:'',
        confirmPwd:''
    }
  },
  mounted(){
  },
  methods:{
    login(){
        if (!this.pwd) {
            this.$vux.toast.show({
                text: '旧密码不能为空',
                type:'cancel'
            })
            return;
        }
        if (!this.newPwd) {
            this.$vux.toast.show({
                text: '新密码不能为空',
                type:'cancel'
            })
            return;
        }
        if (!this.confirmPwd) {
            this.$vux.toast.show({
                text: '确认新密码不能为空',
                type:'cancel'
            })
            return;
        }
        if (this.confirmPwd!=this.newPwd) {
            this.$vux.toast.show({
                text: '确认密码不一致',
                type:'cancel'
            })
            return;
        }
        if (this.pwd==this.newPwd) {
            this.$vux.toast.show({
                text: '新密码与旧密码不能重复',
                type:'cancel'
            })
            return;
        }
        let  url = CONSTANT.URL.LOGIN.CHANGEPWD,
            param = {
                pwd:this.pwd,
                newPwd:this.newPwd,
                confirmPwd:this.confirmPwd
            }
        common.requestAjax(url,{},param,(res)=>{
            if(res.status == 200){
                this.$vux.toast.show({
                    text: res.msg
                })
                this.$router.replace('/login');
            }else{
              this.$vux.toast.show({
                    text:res.msg,
                    type:'cancel'
                })
            }
        })         
      }
  }
}
</script>

<style lang="scss">
 .password-wrap{
    .myself-item{
        margin-left: .29rem;
        font-size: .32rem;
        color: #333;
        .item-list{
            height: .98rem;
            border-bottom: 1px solid #DEDEDE;
            padding-right: .3rem;
            input{
                height: .98rem;
                border: 0px;
                width: 60%;
                &:focus{
                    outline: 0px;
                }
            }
            input[placeholder], [placeholder], *[placeholder] { 
                color:#999 !important; 
                text-align: right;
                font-size: .32rem;
                
            } 
        }
    }
    .footer-submit{
        width: 6.9rem;
        height: .88rem;
        background-color: #0063AE;
        border-radius: 4px;
        -webkit-border-radius: 4px;
        text-align: center;
        color: #fff;
        font-size: .34rem;
        line-height:.88rem;
        margin: 5.74rem auto 0;
    }
 }
</style>
